function add (b) {
    let a = this.valueOf()
    let precisionA = (a.toString().split('.')[1] || '').length
    let precisionB = (b.toString().split('.')[1] || '').length
    let base = Math.pow(10, Math.max(precisionA, precisionB))

    return (base * a + base * b) / base
}

function minus (b) {
    return this.valueOf().add(-b)
}

function multiply (b) {
    let a = this.valueOf()
    let precisionA = (a.toString().split('.')[1] || '').length
    let precisionB = (b.toString().split('.')[1] || '').length
    let base = Math.pow(10, Math.max(precisionA, precisionB))

    return (base * a) * (base * b) / base / base
}

function divide (b) {
    let a = this.valueOf()
    let precisionA = (a.toString().split('.')[1] || '').length
    let precisionB = (b.toString().split('.')[1] || '').length
    let base = Math.pow(10, Math.max(precisionA, precisionB))

    return (base * a) / (base * b)
}

module.exports = {
    add,
    minus,
    multiply,
    divide
}
